<template>
  <div>
    <div class="w">
      <div class="signIn">
        <h2>开始准备好好吃饭</h2>
        <div class="inputs">
          <h3>手机号登录</h3>
          <div class="phone">
            <input type="text" placeholder="输入手机号" v-model="phone" />
          </div>
          <div class="signInbtn">
            <button @click="signInbtn">手机号一键登录</button>
          </div>
          <p>
            <input
              type="checkbox"
              @click="checked = !checked"
              :checked="checked"
            />
            我已经阅读并同意下厨房<span>《用户协议》</span>和<span
              >《隐私策略》</span
            >
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      property: "value",
      checked: false,
      phone: null,
    };
  },
  methods: {
    signInbtn() {
      this.$emit("signInbtn",this.phone)
      if (this.checked) {
        let reg =
          /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
        if (!reg.test(this.phone)) {
          Toast("请输入正确手机号码与密码");
          return;
        } else {
          window.sessionStorage.setItem("token", this.phone);
          Toast("登陆成功");
          this.$router.push("/homeView");
        }
      } else {
        Toast("注册登录前请先阅读相关协议");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.signIn {
  padding: 0 30px;
  padding-top: 64px;
  h2 {
    height: 60px;
    font-size: 25px;
    line-height: 60px;
  }
  .inputs {
    h3 {
      height: 60px;
      font-size: 20px;
    }
    .phone {
      height: 34px;
      padding: 8px 30px;
      border-bottom: 1px solid #999;
      input {
        height: 34px;
        border: 0;
        outline: none;
      }
    }
    .signInbtn {
      margin-top: 20px;
      text-align: center;
      button {
        width: 100%;
        height: 55px;
        font-weight: bold;
        border: 0;
        outline: none;
        background-color: #5dca6f;
        border-radius: 10px;
        color: white;
      }
    }
    p {
      margin-top: 20px;
      text-align: center;
      font-size: 12px;
      color: #a9a9a9;
      span {
        color: #f89076;
      }
    }
  }
}
</style>